import static org.junit.Assert.assertEquals;

import org.junit.Test;


public class CommandTest {
	
	Task testTask = new Task();
	EditCommand edit = new EditCommand();
	@Test
	public void test() throws PopupClosedException, 
			TaskNotFoundException, NotUniqueException, InvalidInputException, ActionUnavailableException {
		testAddCommand();
		testEditCommand();
		testUndoCommand();
		testRedoCommand();
		testViewCommand();
		testDeleteCommand();
	}

	private void testAddCommand() throws PopupClosedException {
		AddCommand add = new AddCommand();
		testTask.title = "add this";
		testTask.project = "Test";
		add.task = testTask;
		SingleTaskReply r = (SingleTaskReply) add.execute();
		assertEquals("add execute", testTask, r.task);
	}

	private void testEditCommand() throws TaskNotFoundException, 
			PopupClosedException, NotUniqueException, InvalidInputException {
		edit.isEditingDescription = true;
		Task editTask = new Task();
		editTask.description = "testing testing";
		edit.taskTitle = "add this";
		edit.newTaskDetails = editTask;
		SingleTaskReply r = (SingleTaskReply) edit.execute();
		assertEquals("edit execute", testTask, r.task);
	}
	
	private void testUndoCommand() throws ActionUnavailableException {
		UndoCommand undo = new UndoCommand();
		CommandReply c = (CommandReply) undo.execute();
		assertEquals("undo execute", edit, c.command);
	}
	
	private void testRedoCommand() throws ActionUnavailableException {
		RedoCommand redo = new RedoCommand();
		CommandReply c = (CommandReply) redo.execute();
		assertEquals("redo execute", edit, c.command);
	}

	private void testViewCommand() throws TaskNotFoundException, NotUniqueException {
		ViewCommand view = new ViewCommand();
		view.taskTitle = "add this";
		SingleTaskReply r = (SingleTaskReply) view.execute();
		assertEquals("view execute", testTask, r.task);
	}
	
	private void testDeleteCommand() throws TaskNotFoundException, NotUniqueException {
		DeleteCommand delete = new DeleteCommand();
		delete.taskTitle = "add this";
		SingleTaskReply r = (SingleTaskReply) delete.execute();
		assertEquals("delete execute", testTask, r.task);
	}

}